//net install rdrobust, from(http://www-personal.umich.edu/~cattaneo/software/rdrobust/stata) replace
//net install rdrobust, from(https://raw.githubusercontent.com/rdpackages/rdrobust/master/stata) replace

	
global replica_dir="<add path to your working directory>"
global data_dir="$replica_dir/data"
global output_dir="$replica_dir/output"

use "$data_dir/panel_simce4b8_sned_studlvl.dta", clear

				
/*----------------------------------------------------------------------------- 

Figure A.7: Student outcome discontinuity plots, Grade 8 cohorts

*/



global depvars "mate_post lect_post nat_post" 

collapse (mean) ${depvars} (firstnm) st_ind25 st_ind10  , by(rbd sned_yr)


la var mate_post "Grade 8 Math Score"
la var lect_post "Grade 8 Reading Score"
la var nat_post  "Grade 8 Natural Sciences"


foreach i in 25{
foreach y of global depvars{
local label_`y': variable label `y'

rdplot `y' st_ind`i'   if abs(st_ind`i') <= 1.5, h(1.5)  graph_options(legend(off) graphregion(color(white)) xtitle("SNED index centered at zero") /*ytitle("`label_`y''")*/ title("`label_`y'', 100% vs. 60%") xlab(-1.5(0.5)1.5) ylab(235(15)280))   binselect(esmv)  kernel(uni) p(2) masspoints(off)   ///
 
graph export "$output_dir/graph_8b4_`y'_`i'.png", as(png) replace

}
}

foreach i in 10{
foreach y of global depvars{
local label_`y': variable label `y'

rdplot `y' st_ind`i'   if abs(st_ind`i') <= 1.5, h(1.5)  graph_options(legend(off) graphregion(color(white)) xtitle("SNED index centered at zero") /*ytitle("`label_`y''")*/ title("`label_`y'', 60% vs. none") xlab(-1.5(0.5)1.5) ylab(235(15)280))    binselect(esmv)  kernel(uni) p(2) masspoints(off)   ///
 
graph export "$output_dir/graph_8b4_`y'_`i'.png", as(png) replace

}
}

